package com.lmh.ymw.service.news;

import com.lmh.ymw.entity.News;
import com.lmh.ymw.mapper.news.NewsDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class NewsServiceImpl implements NewsService {
    @Autowired
    private NewsDao newsDao;
    @Override
    public Boolean addNews(News news) {
        int i = newsDao.insertSelective(news);
        if (i != 0) {
            return true;
        }else {
            return false;
        }
    }

    @Override
    public News findNewsById(Integer parameter) {
        News news = newsDao.selectByPrimaryKey(parameter);
        return news;
    }

    @Override
    public Boolean deleteNews(Integer parameter) {
        int i = newsDao.deleteByPrimaryKey(parameter);
        if (i != 0) {
            return true;
        }else {
            return false;
        }
    }

    @Override
    public List<News> queryNewsList() {
        List<News> news = newsDao.selectAll();
        return news;
    }

    @Override
    public boolean update(News news) {
        int i = newsDao.updateByPrimaryKeySelective(news);
        if (i != 0) {
            return true;
        }else {
            return false;
        }
    }
}
